<?php
require_once dirname(__FILE__) . '/../../common.inc.php';
require_once dirname(__FILE__) . '/Plugin.class.php';
$obj = new Plugin();
$myPdo = DbUtils::createPdoInst();

try {
  $plugin = new stdClass();
  $plugin->track_id = MiscUtils::unique();
  $plugin->name = $obj->name;
  $plugin->folder = $obj->folder;
  DbUtils::add($myPdo, 'pz_plugin', $plugin);
} catch (PDOException $e) {
  echo $e->getMessage();
  return;
}

try {
  $sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . $obj->folder . "_config`(
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `track_id` varchar(16) UNIQUE,
           `instance_id` int,
           `width` int,
           `height` int
          )";
  $myPdo->exec($sql);
  
  $sql = "CREATE TABLE IF NOT EXISTS `" . TABLE_NAME_PREFIX_PLUGIN . $obj->folder . "_image`(
           `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
           `track_id` varchar(16) UNIQUE,
           `instance_id` int,
           `name` varchar(128),
           `name_on_server` varchar(64),
           `size` float,
           `width` float,
           `height` float,
           `link` varchar(512)
          )";
  $myPdo->exec($sql);
  echo 'Completed Successfully.';
} catch (PDOException $e) {
  echo $e->getMessage();
}
?>